﻿// =================================================================== 
// 项目说明
//====================================================================
// 
// 文件： SYS_OPERATOR_AWAKE.cs
// 项目名称：


// 创建时间：2013/3/19
// 负责人：
// ===================================================================
using System;
using System.Data;
using CommonLib.Model;
using CommonLib.IDAL;
using CommonLib.DALFactory;

namespace CommonLib.BLL
{
    /// <summary>
    ///   的BLL层


    /// </summary>
    public class SYS_OPERATOR_AWAKE : SYS_OPERATOR_AWAKEBLLBase
    {
		#region ----------变量定义----------
		#endregion
		
		#region ----------构造函数----------
		/// <summary>
		/// 默认构造函数


		/// </summary>
		public SYS_OPERATOR_AWAKE()
		{
		}
		#endregion
		
		#region----------函数定义---------
        public static string SaveAWAKE(CommonLib.Model.SYS_OPERATOR_AWAKE Oper_Model, CommonLib.Model.SYS_AUTO_AWAKE Auto_Model)
        {
            CommonLib.BLL.MyTransaction myTrans = new CommonLib.BLL.MyTransaction();
            string sMsg = "";
            try
            {
                myTrans.BeginTransaction();
                CommonLib.BLL.SYS_AUTO_AWAKE.Add(myTrans, Auto_Model);
                CommonLib.BLL.SYS_OPERATOR_AWAKE.Add(myTrans, Oper_Model);
                myTrans.CommitTran();
            }
            catch (Exception ex)
            {
                myTrans.RollBackTran();
                sMsg = ex.Message;
            }

            return sMsg;
        }

        public static string UpdateAWAKE(CommonLib.Model.SYS_AUTO_AWAKE Auto_Model)
        {
            CommonLib.BLL.MyTransaction myTrans = new CommonLib.BLL.MyTransaction();
            string sMsg = "";
            try
            {
                myTrans.BeginTransaction();
                CommonLib.BLL.SYS_AUTO_AWAKE.Update(myTrans, Auto_Model);
                myTrans.CommitTran();
            }
            catch (Exception ex)
            {
                myTrans.RollBackTran();
                sMsg = ex.Message;
            }

            return sMsg;
        }

        public static string DeleteAWAKE(int Awake_Id)
        {
            CommonLib.BLL.MyTransaction myTrans = new CommonLib.BLL.MyTransaction();
            string sMsg = "";
            try
            {
                myTrans.BeginTransaction();
                CommonLib.BLL.SYS_OPERATOR_AWAKE.DeleteFK(myTrans, "AWAKE_ID='" + Awake_Id + "'");
                CommonLib.BLL.SYS_AUTO_AWAKE.DeleteFK(myTrans, "AWAKE_ID='" + Awake_Id + "'");
                myTrans.CommitTran();
            }
            catch (Exception ex)
            {
                myTrans.RollBackTran();
                sMsg = ex.Message;
            }

            return sMsg;
        }


        public static string SelectSave(DataTable dt)
        {
            CommonLib.BLL.MyTransaction myTrans = new CommonLib.BLL.MyTransaction();
            string sMsg = "";
            try
            {
                myTrans.BeginTransaction();
                foreach (DataRow dr in dt.Rows)
                {
                    CommonLib.Model.SYS_OPERATOR_AWAKE model = new CommonLib.Model.SYS_OPERATOR_AWAKE();
                    model.AWAKE_ID = int.Parse(dr["AWAKE_ID"].ToString());
                    model.USER_TYPE = int.Parse(dr["USER_TYPE"].ToString());
                    model.USER_ID = dr["USER_ID"].ToString();
                    CommonLib.BLL.SYS_OPERATOR_AWAKE.Add(myTrans, model);
                }
                myTrans.CommitTran();
            }
            catch (Exception ex)
            {
                myTrans.RollBackTran();
                sMsg = ex.Message;
            }

            return sMsg;
        }
		#endregion
	}
}
